package com.topnav.mc.admin.dao.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.topnav.mc.admin.entity.DeviceFavorite;
import com.topnav.mc.admin.entity.bean.DeviceFavoriteBean;
import com.topnav.mc.admin.entity.param.DeviceFavoriteParam;
import com.topnav.mc.base.mc.McMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author: kenny
 * @Date: 2024/1/9 16:51
 */
@Mapper
public interface DeviceFavoriteMapper extends McMapper<DeviceFavorite, DeviceFavoriteBean, DeviceFavoriteParam> {
    String commSql = " SELECT f.*," +
            " d.code AS deviceCode, d.name AS deviceName, d.coordinate_system AS coordinateSystem," +
            " u.name AS userName, u.code AS userCode " +
            " FROM mc_device_favorite f " +
            " LEFT JOIN mc_device d ON f.device_id = d.id " +
            " LEFT JOIN mc_user u ON f.user_id = u.id " +
            " ${ew.customSqlSegment}";
    @Select(commSql)
    DeviceFavoriteBean selectInfoOne(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    List<DeviceFavoriteBean> selectInfoList(@Param(Constants.WRAPPER) Wrapper queryWrapper);

    @Select(commSql)
    Page<DeviceFavoriteBean> selectInfoPage(Page<DeviceFavoriteParam> page, @Param(Constants.WRAPPER) Wrapper queryWrapper);
}
